import wepy from 'wepy'
import { fetch } from '../utils/fetch'

module.exports = {
  // 短信验证码
  smsCode (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/user/_guest/smsCode',
      data
    }, options)
  },
  // 登陆
  login (data, options) {
    console.log(wepy.$appConfig)
    return fetch({
      url: wepy.$appConfig.webOpenBasePath + '/v1/muser/_guest/login',
      data
    }, options)
  },
  // 首页商品
  indexProduct (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/index',
      data
    }, options)
  },
  // 热门推荐商品
  indexHotProduct (options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/home/goods'
    }, options)
  },
  // 首页banner
  indexBanner (options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/guest/adList',
      data: {
        adsType: 'banner',
        showPosition: 61,
        rows: 10
      }
    }, options)
  },
  hotCity (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/hotCity',
      data
    }, options)
  },
  // 经纬度查询地理位置
  location (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/city/selectDictAreaByLocal',
      data
    }, options)
  },
  // 商品详情
  productDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/ticket/getDetail',
      data
    }, options)
  },
  // 提交订单
  orderSubmit (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/ticket/createOrder',
      methods: 'POST',
      data
    }, options)
  },
  // 订单提交 服务卡之前
  // orderSubmit (data, options) {
  //   return fetch({
  //     url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/saveOrder/tickertOrder',
  //     methods: 'POST',
  //     data
  //   }, options)
  // },
  // 参赛人 列表
  playerList (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/list',
      data
    }, options)
  },
  // 新增参赛人
  playerAdd (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/insert',
      methods: 'POST',
      data
    }, options)
  },
  // 删除参赛人
  playerDel (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/delete',
      methods: 'DELETE',
      data
    }, options)
  },
  // 编辑参赛人
  playerEdit (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/update',
      methods: 'POST',
      data
    }, options)
  },
  // 获取参赛人详情
  playerDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/userinfo',
      data
    }, options)
  },
  // 获取订单列表
  orderList (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/orderList',
      data
    }, options)
  },
  // 获取订单详情
  orderDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/ticket/getOrderDetail',
      data
    }, options)
  },
  // 取消订单
  orderDel (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/order/cancelGoodsOrder',
      methods: 'POST',
      data
    }, options)
  },
  // 获取订单缺详情
  getConfirmDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/ticket/getSkuDetail',
      data
    }, options)
  },
  // 获取取票人信息
  getTicketHolder (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/ticket/getTicketHolderInfo',
      data
    }, options)
  },
  // 微信支付
  wxPaySign (orderNumber, options) {
    const userinfo = wx.getStorageSync('htxk_token')
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/payment/info',
      data: {
        orderNumber: orderNumber,
        payType: 'without.applet.wechat',
        openId: userinfo.openId
      }
    }, options)
  },
  // 获取订单参赛人
  orderPlayer (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/ticketUser/select/tickertOrder',
      data
    }, options)
  },
  // 采购详情
  purhaseDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/getAppPurchaseById',
      data
    }, options)
  },
  // 采购列表
  purhaseList (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/getAppPurchaseByPage',
      data
    }, options)
  },
  // 采购添加
  purhaseAdd (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/saveAppPurchase',
      methods: 'POST',
      data
    }, options)
  },
  // 搜索-热门关键字 
  searchHotKeys (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/hotKeys',
      data
    }, options)
  },
  // 增加收藏 
  favoriteAdd (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/user/userFavorite',
      methods: 'POST',
      data
    }, options)
  },
  // 删除收藏 
  favoriteDel(data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/user/userFavorite',
      methods: 'DELETE',
      data
    }, options)
  },
  // 收藏列表
  favoriteList(data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/userFavoriteForTicketList',
      data
    }, options)
  },
  //意见反馈
  feedback (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/user/_feedback',
      methods: 'POST',
      data
    }, options)
  },
  // 日历表 - 获取月份活动统计
  calendarDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/miniapp/play/count',
      data
    }, options)
  },
  //  获取物流
  logisticsDetail (data, options) {
    return fetch({
      url: wepy.$appConfig.h5BasePath + '/v1/order/goodsOrder/logisticsInfo',
      data
    }, options)
  }
}
